package com.hui.wanxin.web.controller;


import com.hui.wanxin.web.entity.UserLogin;
import com.hui.wanxin.web.service.UserService;
import com.hui.wanxin.web.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.HttpRequestHandler;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 灰灰
 * @since 2023-10-14
 */
@RestController
@RequestMapping("/web/user")
public class UserController {


    @Autowired
    private UserService userService;

    @PostMapping("/login")
    public R login(@RequestBody UserLogin userLogin){
        return userService.login(userLogin);
    }

    @PostMapping("/bandPhone")
    public R bandPhone(@RequestBody UserLogin userLogin, HttpServletRequest request){
        String openid =(String) request.getAttribute("openid");
        return userService.bandPhone(userLogin,openid);
    }

}

